Page({
  data: {
    types: ['查询订单'],
    selectedType: 0,
    showEmpty: false,
    name: '',
    phone: ''
  },
  onNameInput(e) {
    this.setData({
      name: e.detail.value
    });
  },
  onPhoneInput(e) {
    this.setData({
      phone: e.detail.value
    });
  },
  onTypeChange(e) {
    this.setData({
      selectedType: e.detail.value
    });
  },
  onSubmit() {
    const { name, phone, types, selectedType } = this.data;
    if (!name) {
      wx.showToast({
        title: '请输入姓名',
        icon: 'none'
      });
      return;
    }
    if (!phone) {
      wx.showToast({
        title: '请输入手机号',
        icon: 'none'
      });
      return;
    }
    // 简单手机号格式校验
    if (!/^1[3-9]\d{9}$/.test(phone)) {
      wx.showToast({
        title: '手机号格式不正确',
        icon: 'none'
      });
      return;
    }
    if (types[selectedType] === '查询订单') {
      // 这里应有实际查询逻辑，演示直接显示无订单
      this.setData({
        showEmpty: true
      });
      wx.showModal({
        title: '提示',
        content: '查询结束',
        showCancel: false
      });
    } else {
      wx.showToast({
        title: '提交成功',
        icon: 'success'
      });
    }
  }
});